<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./css/index.css">
</head>

<body>
    <div class="wrap">
        <header class="header">
            <ul class="list">
                <li class="active">未使用</li>
                <li>已使用</li>
                <li>已过期</li>
            </ul>
        </header>
        <main class="main">
            <div class="boxList">
                <ol>
                    <li>
                        <b>$5</b>
                        <p>满减券</p>
                    </li>
                    <li>
                        <b>￥9.5</b>
                        <p>折扣券</p>
                    </li>
                    <li>
                        <b>￥10</b>
                        <p>满减券</p>
                    </li>
                    <li>
                        <b>￥10</b>
                        <p>满减券</p>
                    </li>
                </ol>
            </div>
        </main>
    </div>
    <script>
        let ul = document.querySelector('.list');
        let lis = Array.from(ul.querySelectorAll('li'));
        console.log(lis)
        lis.forEach((item, index) => {
            item.onclick = () => {
                for (var i = 0; i < lis.length; i++) {
                    lis[i].classList.remove('active')
                }
                item.classList.add('active')
            }
        })
    </script>
</body>

</html>